home *** CD-ROM | disk | FTP | other *** search
/ MacAdvocate 2 / apple-mac-advocate-ii-fall-1997.iso / mac / MacOS / Other Installers / LaserWriter 8.4.1 Installer / LaserWriter Disk 1 / PL.CommonRsrc / PL.CommonRsrc.rsrc / PS_-8176 < prev    next >
Encoding:
Text File  |  1996-09-10  |  6.0 KB  |  482 lines

  1. %%BeginFile: lw8_level1_colorimage-2.0
  2. /testsystemdict
  3. {
  4. where
  5. {
  6. systemdict eq
  7. {
  8. T
  9. }{
  10. F
  11. }ifelse
  12. }{
  13. F
  14. }ifelse
  15. }bd
  16. /rgbclut Z
  17. /bwclut Z
  18. /ncolors 1 def
  19. /colorimage where{pop T}{F}ifelse
  20. {
  21. /ncolors 0
  22. statusdict begin
  23. /processcolors where
  24. {
  25. pop
  26. pop
  27. processcolors
  28. }{
  29. /deviceinfo where
  30. {pop deviceinfo/Colors known
  31. {pop{deviceinfo/Colors get}}if
  32. }if
  33. }ifelse
  34. end
  35. store
  36. ncolors 0 ne
  37. {
  38. /colorimage testsystemdict
  39. /setcolortransfer testsystemdict
  40. /currentcolortransfer testsystemdict
  41. /currentcmykcolor testsystemdict
  42. and and and not
  43. {
  44. /ncolors 0 store
  45. }if
  46. }if
  47. }if
  48. ncolors 1 ne ncolors 3 ne ncolors 4 ne and and{/ncolors 0 store}if
  49. ncolors 1 ne dup startnoload
  50. /expandfactor Z
  51. /expandbw
  52. {
  53. expandfactor mul round cvi bwclut exch get 255 div
  54. }bd
  55. /:k
  56. {
  57. pop/bwclut xs
  58. bpc dup 8 eq
  59. {
  60. pop 255
  61. }{
  62. 4 eq
  63. {
  64. 15
  65. }{
  66. 3
  67. }ifelse
  68. }ifelse
  69. /expandfactor xs
  70. [
  71. /expandbw load/exec load dup
  72. currenttransfer exch
  73. ]cvx bind settransfer
  74. iw ih bpc[iw 0 0 ih 0 0]setupimageproc
  75. image
  76. }bd
  77. endnoload
  78. ncolors dup 3 eq exch 4 eq or
  79. not dup startnoload
  80. /Dclut Z
  81. /Cclut Z
  82. /Bclut Z
  83. /Aclut Z
  84. /ncompute Z
  85. /rclut Z
  86. /gclut Z
  87. /bclut Z
  88. /bit3x Z
  89. /bit1x Z
  90. /concatutil
  91. {
  92. /exec load
  93. 7 -1 roll/exec load
  94. }bd
  95. /defsubclut
  96. {
  97. 1 add getinterval store
  98. }bd
  99. /spconcattransfer
  100. {
  101. /Dclut xs
  102. /Cclut xs
  103. /Bclut xs
  104. /Aclut xs
  105. /ncompute exch load store
  106. currentcolortransfer
  107. [
  108. {
  109. Aclut ncompute
  110. }
  111. concatutil
  112. ]cvx
  113. [
  114. {
  115. Bclut ncompute
  116. }
  117. concatutil
  118. ]cvx
  119. [
  120. {
  121. Cclut ncompute
  122. }
  123. concatutil
  124. ]cvx
  125. [
  126. {
  127. Dclut ncompute
  128. }
  129. concatutil
  130. ]cvx
  131. setcolortransfer
  132. }bd
  133. /setuprgbcluts
  134. {
  135. /bit3x
  136. rgbclut length
  137. 3 sub
  138. store
  139. /bit1x bit3x 3 idiv store
  140. /rclut rgbclut store
  141. /gclut rclut 1 bit3x defsubclut
  142. /bclut rclut 2 bit3x defsubclut
  143. }bd
  144. endnoload
  145. ncolors 3 ne
  146. dup startnoload
  147. /str Z
  148. /len Z
  149. /smlen Z
  150. /rstr Z
  151. /gstr Z
  152. /bstr Z
  153. /kstr Z
  154. /cmykcluttorgbclut
  155. {
  156. /str xs
  157. /len str length store
  158. /smlen len 4 idiv store
  159. /rstr str store
  160. /gstr str 1 len 1 sub getinterval store
  161. /bstr str 2 len 2 sub getinterval store
  162. /kstr str 3 len 3 sub getinterval store
  163. 0 1 smlen 1 sub
  164. {
  165. dup 3 mul/str xs 4 mul/len xs
  166. kstr len get
  167. rstr dup len get
  168. 2 index add
  169. 255 exch sub dup 0 lt{pop 0}if
  170. str exch put
  171. gstr dup len get
  172. 2 index add
  173. 255 exch sub dup 0 lt{pop 0}if
  174. str exch put
  175. bstr dup len get
  176. 2 index add
  177. 255 exch sub dup 0 lt{pop 0}if
  178. str exch put
  179. pop
  180. }for
  181. rstr 0 smlen 3 mul getinterval
  182. }bd
  183. /3compute
  184. {
  185. exch bit3x
  186. mul
  187. round
  188. cvi
  189. get 255 div
  190. }bd
  191. /:k
  192. {
  193. /rgbclut xs
  194. pop
  195. $c devc eq
  196. {
  197. rgbclut cmykcluttorgbclut/rgbclut xs
  198. }if
  199. setuprgbcluts
  200. /3compute rclut gclut bclut dup
  201. spconcattransfer
  202. iw ih bpc[iw 0 0 ih 0 0]
  203. [
  204. setupimageproc/exec load
  205. /dup load dup
  206. ]cvx
  207. {}{}T 3 colorimage
  208. }bd
  209. endnoload
  210. ncolors 4 ne
  211. dup startnoload
  212. /cmykindex Z
  213. /bit4x Z
  214. /cmykclut Z
  215. /cclut Z
  216. /mclut Z
  217. /yclut Z
  218. /kclut Z
  219. /ftoint
  220. {
  221. 1 exch sub 255 mul round cvi
  222. }bd
  223. /stuffclut
  224. {
  225. cmykindex 3 -1 roll put
  226. }bd
  227. /4compute{exch bit4x mul round cvi get 255 div}bd
  228. /invalidcolortable? T def
  229. /computecmykclut
  230. {
  231. setuprgbcluts
  232. /bit4x
  233. rgbclut length
  234. 3 idiv
  235. 4 mul
  236. 4 sub
  237. store
  238. /cmykclut bit4x 4 add string store
  239. /cclut cmykclut store
  240. /mclut cclut 1 bit4x defsubclut
  241. /yclut cclut 2 bit4x defsubclut
  242. /kclut cclut 3 bit4x defsubclut
  243. /cmykindex 0 store
  244. 0 1 bit1x
  245. {
  246. dup/cmykindex exch
  247. bit1x exch sub
  248. 4 mul store
  249. 3 mul dup
  250. rclut exch get 255 div
  251. exch dup
  252. gclut exch get 255 div
  253. exch
  254. bclut exch get 255 div
  255. setrgbcolor currentcmykcolor
  256. ftoint
  257. kclut stuffclut
  258. ftoint
  259. yclut stuffclut
  260. ftoint
  261. mclut stuffclut
  262. ftoint
  263. cclut stuffclut
  264. }for
  265. }bd
  266. /innew Z
  267. /reverse4clut
  268. {
  269. dup length dup 4 sub/innew xdf
  270. string dup
  271. 3 -1 roll
  272. {
  273. 255 exch sub
  274. innew exch
  275. put dup
  276. innew 4 mod 3 eq
  277. {
  278. /innew innew 7 sub def
  279. }{
  280. /innew innew 1 add def
  281. }ifelse
  282. }forall
  283. pop
  284. }bd
  285. /:k
  286. {
  287. /rgbclut xs
  288. pop
  289. $c devc ne
  290. {
  291. computecmykclut
  292. }{
  293. /bit4x
  294. rgbclut length 4 sub
  295. store
  296. /cmykclut rgbclut reverse4clut store
  297. /cclut cmykclut store
  298. /mclut cclut 1 bit4x defsubclut
  299. /yclut cclut 2 bit4x defsubclut
  300. /kclut cclut 3 bit4x defsubclut
  301. }ifelse
  302. /4compute cclut mclut yclut kclut spconcattransfer
  303. iw ih bpc[iw 0 0 ih 0 0]
  304. [
  305. setupimageproc/exec load
  306. /dup load dup dup
  307. ]cvx
  308. {}{}{}
  309. T 4 colorimage
  310. }bd
  311. endnoload
  312. ncolors 0 ne
  313. dup startnoload
  314. /byte Z
  315. /$x Z
  316. /padfix Z
  317. /lookupandstore
  318. {
  319. 3 mul
  320. 3 getinterval
  321. putinterval exch
  322. 3 add exch 3 copy
  323. }bd
  324. /8lookup/lookupandstore load store
  325. /4lookup
  326. {
  327. /byte 1 index store
  328. -4 bitshift
  329. lookupandstore
  330. byte 15 and
  331. lookupandstore
  332. }bd
  333. /2lookup
  334. {
  335. /byte 1 index store
  336. -6 bitshift
  337. lookupandstore
  338. byte -4 bitshift
  339. 3 and
  340. lookupandstore
  341. byte -2 bitshift
  342. 3 and
  343. lookupandstore
  344. byte 3 and
  345. lookupandstore
  346. }bd
  347. /colorexpand
  348. {
  349. $x 0 rgbclut
  350. 3 copy
  351. 7 -1 roll
  352. /$l load
  353. forall
  354. pop pop pop pop pop
  355. 0 padfix getinterval
  356. }bd
  357. /createexpandstr
  358. {
  359. /$x exch $z length mul string store
  360. }bd
  361. /:k
  362. {
  363. /rgbclut xs
  364. /bwclut xs
  365. /$l
  366. bpc 8 eq
  367. {
  368. 3 createexpandstr
  369. /8lookup
  370. }{
  371. bpc 4 eq
  372. {
  373. 6 createexpandstr
  374. /4lookup
  375. }{
  376. 12 createexpandstr
  377. /2lookup
  378. }ifelse
  379. }ifelse
  380. load store
  381. /padfix 3 iw mul store
  382. iw ih 8[iw 0 0 ih 0 0]
  383. [setupimageproc/exec load/colorexpand load/exec load]cvx
  384. F 3 colorimage
  385. }bd
  386. endnoload
  387. /colorimage where
  388. {
  389. systemdict eq
  390. {
  391. systemdict/setcmykcolor known
  392. }{
  393. T
  394. }ifelse
  395. }{
  396. F
  397. }ifelse
  398. dup not startnoload
  399. /:l
  400. {
  401. iw ih 8[iw 0 0 ih 0 0]
  402. setupimageproc F 3
  403. $c devc eq
  404. {
  405. pop 4
  406. }if
  407. colorimage
  408. }bd
  409. dup not endnoload
  410. dup startnoload
  411. /str Z
  412. /len Z
  413. /smlen Z
  414. /rstr Z
  415. /gstr Z
  416. /bstr Z
  417. /rgbtogray
  418. {
  419. /str xs
  420. /len str length store
  421. /smlen len 3 idiv store
  422. /rstr str store
  423. /gstr str 1 len 1 sub getinterval store
  424. /bstr str 2 len 2 sub getinterval store
  425. str dup
  426. 0 1 smlen 1 sub
  427. {
  428. dup 3 mul
  429. rstr 1 index get .3 mul
  430. gstr 2 index get .59 mul add
  431. bstr 3 -1 roll get .11 mul add
  432. round cvi
  433. put dup
  434. }for
  435. pop 0 smlen getinterval
  436. }bd
  437. /kstr Z
  438. /cmyktogray
  439. {
  440. /str xs
  441. /len str length store
  442. /smlen len 4 idiv store
  443. /rstr str store
  444. /gstr str 1 len 1 sub getinterval store
  445. /bstr str 2 len 2 sub getinterval store
  446. /kstr str 3 len 3 sub getinterval store
  447. str dup
  448. 0 1 smlen 1 sub
  449. {
  450. dup 4 mul
  451. rstr 1 index get .3 mul
  452. gstr 2 index get .59 mul add
  453. bstr 2 index get .11 mul add
  454. kstr 3 -1 roll get add
  455. round cvi
  456. 255 exch sub dup 0 lt{pop 0}if
  457. put dup
  458. }for
  459. pop 0 smlen getinterval
  460. }bd
  461. /:l
  462. {
  463. iw ih 8[iw 0 0 ih 0 0]
  464. [setupimageproc/exec load
  465. $c devc eq
  466. {
  467. /cmyktogray
  468. }{
  469. /rgbtogray
  470. }ifelse
  471. load/exec load]cvx bind
  472. image
  473. }bd
  474. endnoload
  475. /:x
  476. {
  477. iw ih 8[iw 0 0 ih 0 0]
  478. setupimageproc
  479. image
  480. }bd
  481. %%EndFile
  482.